<%--
  Created by IntelliJ IDEA.
  User: 21775
  Date: 2022/4/2
  Time: 14:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>根据id寻找个人信息</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.5.1.js"></script>
    <script type="text/javascript">
        $(function () {
            $(":button").on("click",function () {
                var uid=$(":text").val();
                $.ajax({
                    url:"findUserById",
                    data:{
                        "uid":uid
                    },
                    dataType:"json",
                    success:function (data) {
                        if(data==null) return;
                        var $tr=$("#display");
                        $tr.attr("class","class4");
                        var $tds=$("#display>td");
                        var count=0;
                        console.log(count);
                        $.each(data,function (index,element) {
                            $tds[count].innerText=element;
                            $tds[count].title=index;
                            count++;
                            console.log(count);
                        })
                    }
                })
            })
        })
    </script>
    <style type="text/css">
        .class4{

        }
        .class5{
            display: none;
        }
    </style>
</head>
<body>
    <form>
        <input type="text" width="100px">
        <input type="button" value="查询">
    </form>
    <table border="1">
        <tr>
            <th>uid</th>
            <th>uname</th>
            <th>age</th>
            <th>sex</th>
        </tr>
        <tr class="class5" id="display">
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </table>
</body>
</html>
